<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>父子组件通信</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
    <son @connect="say"></son>
</div>
<script>
    Vue.component('son', {
        template: `<button @click="send">
                点击
             </button>`,
        methods: {
            send () {
                this.$emit('connect',this.msg,this.name);
            }
        },
        data () {
            return {
                msg: '大家好，我是子组件的数据',
                name: '我有名字是dap'
            }
        }
    });

    let vm = new Vue({
        el: "#app",
        methods: {
            say (msg,name) {
                alert(`大家好，我监听到了事件connect的触发:`+msg+`;name=`+name);
            }
        }
    });
</script>
</body>
</html>